package com.tools.app.service.impl;

import com.hm.base.android.mob.service.impl.MobProtocolFactory;
import com.hm.base.android.mob.service.impl.ProtocolWrap;
import com.tools.ad.ADConstant;
import com.tools.ad.BuildConfig;

import java.util.HashMap;
import java.util.Map;

import static com.tools.ad.ADConstant.PROTOCOL_TYPE.INVISIBLE_TYPE;

/**
 * Created by ChenLi on 2017/12/13.
 */

public class AppProtocolFactory extends MobProtocolFactory {

    /**
     * GP推广渠道追踪上报
     *
     * @param referrer
     * @return
     */
    public ProtocolWrap submitReferrer(String referrer, long time) {

        Map<String, String> params = new HashMap<>();
        params.put("referrer", referrer);
        params.put("rts", String.valueOf(time));

        ProtocolWrap pw = new ProtocolWrap();
        //pw.setHost("http://172.26.1.247:8280/");
        pw.setHost(ADConstant.AD_REFERRER_URL);

        if (BuildConfig.PROTOCOL_TYPE == INVISIBLE_TYPE) {
            pw.setEncryptHeader(true);
            pw.setHeaderValues(params);
        } else {
            pw.setUrlParams(params);
        }
        return pw;
    }

}
